﻿using System;
using System.Windows.Forms;
using BCS.Business;

namespace BCS.WinFormAppGui
{
        public partial class PasswordForm : Form
        {
                public PasswordForm()
                {
                        InitializeComponent();
                }

                private void PasswordForm_Load(object sender, EventArgs e)
                {
                        PasswordTextBox.Focus();
                }

                private void OneButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 1;
                }

                private void TwoButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 2;
                }

                private void ThreeButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 3;
                }

                private void FourButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 4;
                }

                private void FiveButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 5;
                }

                private void SixButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 6;
                }

                private void SevenButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 7;
                }

                private void EightButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 8;
                }

                private void NineButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 9;
                }

                private void ZeroButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Text += 0;
                }

                private void ClearButton_Click(object sender, EventArgs e)
                {
                        PasswordTextBox.Clear();
                }

                private void CancelButton_Click(object sender, EventArgs e)
                {
                        Close();
                }

                private void AcceptButton_Click(object sender, EventArgs e)
                {
                        if (PasswordTextBox.Text == "123" + DateTime.Now.Hour)
                        {
                                BusinessCache.Instance.Permission = Permissions.查询权限 | Permissions.修改班组权限;
                                Close();
                                return;
                        }

                        if (PasswordTextBox.Text == "123456" + DateTime.Now.Hour)
                        {
                                BusinessCache.Instance.Permission = Permissions.查询权限 | Permissions.修改班组权限 | Permissions.修改铸坯权限 | Permissions.计数权限 | Permissions.退出权限 | Permissions.修改图像权限;
                                Close();
                                return;
                        }

                        PasswordTextBox.Clear();
                        MessageBox.Show("错误的密码，请重新输入");
                }
        }
}